import { useUserStore } from '@/store/user'
const baseUrl = '/api';
export function commonApi(url: string, method = 'post', body?: any) {
  const userStore = useUserStore()
  return $fetch(`${baseUrl}${url}`, {
    method,
    body,
    headers: {
      // 自动添加Token到请求头
      ...(userStore.token && {
        Authorization: `Bearer ${userStore.token}`
      })
    }
  })
}